import Vue from 'vue'
import axios from 'axios'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets

import Element from 'element-ui'
import './styles/element-variables.scss'

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import './icons' // icon
import './permission' // permission control
import './utils/error-log' // error log

import * as filters from './filters' // global filters
import components from './components' // global component
import globalMethods from './utils/global' // global method
import { addFileUrl } from '@/api/followForms/followForms'

import Moment from 'moment'

//打印pdf
import Print from 'vue-print-nb'



Vue.prototype.$http = axios
    //vxe table
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'

Vue.use(VXETable)

//需要按需引入，先引入vue并引入element-ui
import AFTableColumn from 'af-table-column'
Vue.use(AFTableColumn)

import './assets/fonts/iconfont.css'
import './assets/fonts2/iconfont.css'


// 定义全局时间戳过滤器
Vue.filter('formatDate', function(value) {
    return Moment(value).format('YYYY-MM-DD HH:mm:ss')
})

Vue.filter('formatDateToDay', function(value) {
    return Moment(value).format('YYYY-MM-DD')
})

Vue.filter('formatDateToMinite', function(value) {
    return Moment(value).format('YYYY-MM-DD HH:mm')
})

// value查label
Vue.filter('getLabelByValue', function(array, value) {
    var res = ''
    array.forEach(e => {
        if (String(value) === String(e.value)) {
            res = e.label
        }
    })
    return res
})



Vue.use(Element, {
    size: Cookies.get('size') || 'small'
})

Object.keys(filters).forEach(key => {
    Vue.filter(key, filters[key])
})

Object.keys(components).forEach(key => {
    Vue.component(key, components[key])
})


Vue.prototype.uploadImgUrl=process.env.VUE_APP_BASE_API+addFileUrl
Vue.use(globalMethods)

Vue.config.productionTip = false

new Vue({
    el: '#app',
    router,
    store,
    render: h => h(App)
})
